package com.sxm.yiwei.fragments;


import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.sxm.yiwei.R;
import com.sxm.yiwei.activitis.MineNotification;
import com.sxm.yiwei.activitis.MsgAwardActivity;
import com.sxm.yiwei.activitis.MsgBookActivity;
import com.sxm.yiwei.activitis.MsgCollectActivity;
import com.sxm.yiwei.activitis.MsgFollowActivity;
import com.sxm.yiwei.activitis.MsgLookActivity;
import com.sxm.yiwei.activitis.MsgMsgActivity;
import com.sxm.yiwei.activitis.NoticeMessageActivity;

/**
 * 消息页面
 * A simple {@link Fragment} subclass.
 */
public class MessageFragment extends Fragment implements View.OnClickListener{
    private RadioButton award,follow,look,collect;
    private RelativeLayout msg,book;
    private TextView msgAward,msgLook,msgFollow,msgCollect;
    private RelativeLayout notice;
    private RelativeLayout cityteam;

    public MessageFragment() {
        // Required empty public constructor
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initMessageView();
    }
        // 初始化控件
    private void initMessageView() {
        award = (RadioButton) getView().findViewById(R.id.message_award);
        look = (RadioButton) getView().findViewById(R.id.message_look);
        follow = (RadioButton) getView().findViewById(R.id.message_follow);
        collect = (RadioButton) getView().findViewById(R.id.message_collect);
        msg = (RelativeLayout) getView().findViewById(R.id.message_msg);
        msgAward = (TextView) getView().findViewById(R.id.msg_award);
        msgLook = (TextView) getView().findViewById(R.id.msg_look);
        msgFollow = (TextView) getView().findViewById(R.id.msg_follow);
        msgCollect = (TextView) getView().findViewById(R.id.msg_collect);
        cityteam = (RelativeLayout) getView().findViewById(R.id.message_cityteam);
        notice = (RelativeLayout) getView().findViewById(R.id.message_notice);
        // 设置消息提示数量
        msgAward.setText("110");
        msgFollow.setText("20");
        msgLook.setText("50");
        msgCollect.setText("33");
        cityteam.setOnClickListener(this);

        // 设置点击事件
        this.award.setOnClickListener(this);
        this.look.setOnClickListener(this);
        this.follow.setOnClickListener(this);
        this.collect.setOnClickListener(this);
        msg.setOnClickListener(this);
        notice.setOnClickListener(this);


    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_message, container, false);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.message_cityteam:
                startActivity(new Intent(getActivity(), MineNotification.class));
                break;
            case R.id.message_notice:
                startActivity(new Intent(getActivity(), NoticeMessageActivity.class));
                break;
            case R.id.message_award:
                startActivity(new Intent(getActivity(), MsgAwardActivity.class));
                msgAward.setVisibility(View.INVISIBLE);
                break;
            case R.id.message_look:
                startActivity(new Intent(getActivity(), MsgLookActivity.class));
                msgLook.setVisibility(View.INVISIBLE);
                break;
            case R.id.message_follow:
                startActivity(new Intent(getActivity(), MsgFollowActivity.class));
                msgFollow.setVisibility(View.INVISIBLE);
                break;
            case R.id.message_collect:
                startActivity(new Intent(getActivity(), MsgCollectActivity.class));
                msgCollect.setVisibility(View.INVISIBLE);
                break;
            case R.id.message_msg:
                startActivity(new Intent(getActivity(), MsgMsgActivity.class));
                break;

        }

    }



}
